#include "../include/stlcompat/print.h"
#include <string>
#include <vector>

struct P { int x; };
std::ostream& operator<<(std::ostream& os, const P& p) { return os << "P{" << p.x << "}"; }

int main(){
    kp::print("Hello, {}! ", std::string("world"));
    kp::println("pi ~= {}", 3.14159);

    // 转义示例
    kp::println("{{}} -> {}", 42);

    // 自定义 ostream
    kp::println(std::cerr, "to cerr: {} {} {}", 1, 2.0, P{3});

    // FILE* 输出
    kp::println(stdout, "stdout: {}", 123);

    // --- 更丰富的格式案例 ---
    // 对齐与宽度
    kp::println("left  : [{:<10s}]", "abc");
    kp::println("right : [{:>10s}]", "abc");
    kp::println("center: [{:^10s}]", "abc");

    // 自定义填充
    kp::println("fill  : [{:*^10s}]", "hi");
    kp::println("zpad d: [{:08d}]", 123);

    // 数值前缀与大小写
    kp::println("hex alt lower: {:#x}", 0x2a);
    kp::println("hex alt upper: {:#X}", 0x2a);
    kp::println("oct alt      : {:#o}", 0123);

    // 浮点精度与格式
    kp::println("fixed   : [{:.4f}]", 3.14159);
    kp::println("scientic: [{:.3e}]", 3.14159);
    kp::println("general : [{:.5g}]", 3.14159);

    // 符号控制
    kp::println("sign +  : [{:+d}] [{:+f}]", 42, 3.14);
    kp::println("sign sp : [{: d}] [{: f}]", 42, 3.14);

    // 字符与布尔
    kp::println("char    : [{}] [{}]", 'A', (unsigned char) 'B');
    kp::println("bool    : [{}] [{:d}]", true, true);

    // 精度截断字符串
    kp::println("str.prec: [{:.3s}]", "truncate");

    // 组合案例
    kp::println("combo   : [{:+#010x}] [{:*^12s}]", 255, "fmt");
}
